package Game;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class P2countJFrame extends JFrame implements ActionListener {
    static boolean start=true;
    static int winP=1;

    public P2countJFrame(){
        initJFrame();

        createButton();
    }

    private void initJFrame(){
        setSize(500,500);
        setTitle("帅气的男生制作的小游戏");
        setLocationRelativeTo(null);
        setDefaultCloseOperation(HIDE_ON_CLOSE);
        setLayout(null);

        JLabel text=new JLabel("黑色方胜利！");
        JLabel text2=new JLabel("粉色方胜利！");
        text.setFont(new Font("微软雅黑",0,50));
        text.setBounds(120,50,500,70);
        text2.setFont(new Font("微软雅黑",0,50));
        text2.setBounds(120,50,500,70);
        if(winP==1){
            add(text2);
        }
        if(winP==2){
            add(text);
        }
    }

    private void createButton(){
        JButton jButton1=new JButton("再来一局！");
        jButton1.setBounds(100,190,300,120);
        jButton1.addActionListener(this);
        add(jButton1);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        String command=e.getActionCommand();

        switch (command){
            case "再来一局！":
                start=true;
                dispose();
                if(Snake.getoNum()==1){
                    new GameJFrame1().setVisible(true);
                }
                if(Snake.getoNum()==2){
                    new GameJFrame2().setVisible(true);
                }
                if(Snake.getoNum()==3){
                    new GameJFrame3().setVisible(true);
                }
                if(Snake.getoNum()==4){
                    new GameJFrame4().setVisible(true);
                }
                if(Snake.getoNum()==9){
                    new GameJFrame9().setVisible(true);
                }
                break;
        }
    }
}
